package com.qianfeng.missfood.utils;

import com.qianfeng.missfood.BaseApp;

import java.util.Random;

/**
 * Created by Administrator on 15-8-22.
 */
public class DataUtils {

    private static int securityCode = -1;

    public static String getPhone() {

        String phone = BaseApp.getInstance().getUser().getPhone();
        if (phone != null && phone.length() == 11) {

            StringBuilder sb = new StringBuilder();
            sb.append(phone.substring(0, 3));
            sb.append(" ");
            sb.append(phone.substring(3, 7));
            sb.append(" ");
            sb.append(phone.substring(7, 11));

            return sb.toString();

        }

        return "";
    }

    public static int getRandomCode() {

        Random random = new Random();
        int num = 1000 + random.nextInt(9000);
        DataUtils.setSecurityCode(num);
        return num;
    }

    public static int getSecurityCode() {
        return securityCode;
    }

    public static void setSecurityCode(int securityCode) {

        DataUtils.securityCode = securityCode;
    }
}
